// const baseUrl = 'https://aw2025ht.kangye.xyz/api';
const baseUrl = 'http://localhost:8088';
const uploadRequest = (options = {}) => {
	console.log(options)
	uni.showLoading({
		title: '加载中',
		mask: true,
	})

	return new Promise((resolve, reject) => {
		uni.uploadFile({
			url: baseUrl + options.url,
			headers: {
				'Content-Type': 'multipart/form-data',
				'Authorization': uni.getStorageSync('drivertoken'),
				'Authori-zation': uni.getStorageSync('drivertoken')
			},
			header: options.header,
			filePath: options.filePath, //图片路径
			name: 'avatar', //对应后台接口参数名
			formData: options.formData, //放文件
			success: (res) => {
				resolve(JSON.parse(res.data))
				uni.hideLoading()
			},
			fail: (error) => {
				uni.showToast({
					icon: "error",
					title: '系统错误'
				})
				reject(error)
			}
		})
	})
}

export default uploadRequest